{
 "metadata": {
  "name": "bdf_demo"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "import os\nimport pyNastran\nprint pyNastran.__file__\nprint pyNastran.__version__\n\n\nfrom pyNastran.bdf.bdf import BDF\nfrom pyNastran.utils import object_attributes, object_methods",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "c:\\users\\steve\\desktop\\v0.6_py27\\pyNastran\\__init__.pyc\n0.6.1\n"
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "mode = 0\n\n# create the BDF object\nbdf = BDF()\n\n# read the file from the GUI\n# don't cross-reference\n#bdf.read_bdf(xref=False)\n\nbdf_filename = r'C:\\Users\\Steve\\Dropbox\\pyNastran_examples\\iSat\\ISat_Launch_Sm_Rgd.dat'\nbdf.read_bdf(bdf_filename, xref=False)",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=994    opening 'C:\\\\Users\\\\Steve\\\\Dropbox\\\\pyNastran_examples\\\\iSat\\\\ISat_Launch_Sm_Rgd.dat'\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=734    ---starting BDF.read_bdf of C:\\Users\\Steve\\Dropbox\\pyNastran_examples\\iSat\\ISat_Launch_Sm_Rgd.dat---\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=736    ---reading executive and case control decks---\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=946    found the end of the Case Control Deck!\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=948    finished with Case Control Deck..\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=1242   reading Bulk Data Deck...\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=970    reject card_name = |USET|\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=1017   closing 'C:\\\\Users\\\\Steve\\\\Dropbox\\\\pyNastran_examples\\\\iSat\\\\ISat_Launch_Sm_Rgd.dat'\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=749    ---finished BDF.read_bdf of C:\\Users\\Steve\\Dropbox\\pyNastran_examples\\iSat\\ISat_Launch_Sm_Rgd.dat---\n"
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "#bdf_filename = r'D:\\work\\pynastran_0.7.0_py27\\models\\iSat\\ISat_Launch_Sm_Rgd.dat'\nbdf_filename = r'C:\\Users\\Steve\\Dropbox\\pyNastran_examples\\iSat\\ISat_Launch_Sm_Rgd.dat'\n\n# read the file as a path\nbdf2 = BDF()\nbdf2.read_bdf(bdf_filename, xref=True)",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=994    opening 'C:\\\\Users\\\\Steve\\\\Dropbox\\\\pyNastran_examples\\\\iSat\\\\ISat_Launch_Sm_Rgd.dat'\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=734    ---starting BDF.read_bdf of C:\\Users\\Steve\\Dropbox\\pyNastran_examples\\iSat\\ISat_Launch_Sm_Rgd.dat---\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=736    ---reading executive and case control decks---\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=946    found the end of the Case Control Deck!\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=948    finished with Case Control Deck..\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=1242   reading Bulk Data Deck...\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=970    reject card_name = |USET|\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "INFO:      fname=bdf.pyc                   lineNo=1017   closing 'C:\\\\Users\\\\Steve\\\\Dropbox\\\\pyNastran_examples\\\\iSat\\\\ISat_Launch_Sm_Rgd.dat'\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=crossReference.pyc        lineNo=57     Cross Referencing...\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf.pyc                   lineNo=749    ---finished BDF.read_bdf of C:\\Users\\Steve\\Dropbox\\pyNastran_examples\\iSat\\ISat_Launch_Sm_Rgd.dat---\n"
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "print \"attributes =\", object_attributes(bdf)\nprint \"\"\nprint \"methods =\",object_methods(bdf)\nprint bdf.card_stats()\nprint bdf.card_count",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "attributes = ['active_filename', 'active_filenames', 'aefacts', 'aelinks', 'aelists', 'aeparams', 'aero', 'aeros', 'aestats', 'aesurfs', 'asets', 'bcs', 'bdf_filename', 'bsets', 'cMethods', 'caeros', 'card_count', 'cardsToRead', 'caseControlDeck', 'case_control_lines', 'convectionProperties', 'coords', 'creepMaterials', 'csets', 'dareas', 'dconstrs', 'ddvals', 'debug', 'dequations', 'desvars', 'dlinks', 'dmigs', 'dmijis', 'dmijs', 'dmiks', 'dmis', 'doptprm', 'dresps', 'dvmrels', 'dvprels', 'elements', 'executive_control_lines', 'flfacts', 'flutters', 'foundEndData', 'frequencies', 'gridSet', 'gusts', 'has_case_control_deck', 'iSolLine', 'include_dir', 'loads', 'log', 'materialDeps', 'materials', 'methods', 'mkaeros', 'modelType', 'mpcObject', 'mpcadds', 'mpcs', 'nlparms', 'nlpcis', 'nodes', 'paeros', 'params', 'pbusht', 'pdampt', 'pelast', 'phbdys', 'points', 'properties', 'qsets', 'randomTables', 'reject_cards', 'reject_count', 'rejects', 'rigidElements', 'rsolmap_toStr', 'sets', 'setsSuper', 'sol', 'solMethod', 'spcObject', 'spcadds', 'spcs', 'specialCards', 'splines', 'spoints', 'suports', 'tables', 'thermalMaterials', 'trims', 'tstepnls', 'tsteps', 'uniqueBulkDataCards']\n\nmethods = ['AELink', 'AEParam', 'AEStat', 'Aero', 'Aeros', 'CAero', 'CMethod', 'Coord', 'DConstr', 'DDVal', 'DMIG', 'Desvar', 'Element', 'Elements', 'Flfact', 'Flutter', 'Grav', 'Gust', 'Load', 'Mass', 'MassProperties', 'Material', 'Materials', 'Method', 'NLParm', 'Node', 'Nodes', 'PAero', 'Phbdy', 'Properties', 'Property', 'RandomTable', 'RigidElement', 'SPC', 'Set', 'SetSuper', 'Spline', 'StructuralMaterial', 'Table', 'ThermalMaterial', 'addCard', 'add_AEFACT', 'add_AELINK', 'add_AELIST', 'add_AEPARM', 'add_AERO', 'add_AEROS', 'add_AESTAT', 'add_AESURF', 'add_ASET', 'add_BSET', 'add_CAERO', 'add_CSET', 'add_DAREA', 'add_DCONSTR', 'add_DDVAL', 'add_DEQATN', 'add_DESVAR', 'add_DLINK', 'add_DMI', 'add_DMIG', 'add_DMIJ', 'add_DMIJI', 'add_DMIK', 'add_DRESP', 'add_DVMREL', 'add_DVPREL', 'add_FLFACT', 'add_FLUTTER', 'add_FREQ', 'add_GUST', 'add_LSEQ', 'add_MKAERO', 'add_NLPARM', 'add_NLPCI', 'add_PAERO', 'add_PARAM', 'add_PBUSHT', 'add_PDAMPT', 'add_PELAST', 'add_PHBDY', 'add_QSET', 'add_SESET', 'add_SET', 'add_SPLINE', 'add_SPOINT', 'add_TRIM', 'add_TSTEP', 'add_TSTEPNL', 'add_card', 'add_cmethod', 'add_constraint', 'add_constraint_MPC', 'add_constraint_MPCADD', 'add_constraint_SPC', 'add_constraint_SPCADD', 'add_convection_property', 'add_coord', 'add_creep_material', 'add_damper_element', 'add_element', 'add_load', 'add_mass_element', 'add_material_dependence', 'add_method', 'add_node', 'add_property', 'add_random_table', 'add_rigid_element', 'add_structural_material', 'add_suport', 'add_table', 'add_thermal_BC', 'add_thermal_element', 'add_thermal_load', 'add_thermal_material', 'auto_reject_bdf', 'card_stats', 'coordIDs', 'crossReference', 'cross_reference', 'disableCards', 'disable_cards', 'echoBDF', 'echo_bdf', 'elementIDs', 'getElementIDsWithPID', 'getElementIDsWithPIDs', 'getMaterialIDToPropertyIDsMap', 'getNodeIDToElementIDsMap', 'getNodeIDsWithElement', 'getNodeIDsWithElements', 'getNodes', 'getPropertyIDToElementIDsMap', 'is_reject', 'mass', 'mass_properties', 'materialIDs', 'nCAeros', 'nElements', 'nNodes', 'nodeIDs', 'print_filename', 'process_card', 'propertyIDs', 'readBDF', 'read_bdf', 'resolveGrids', 'resolve_grids', 'setDynamicSyntax', 'set_dynamic_syntax', 'structuralMaterialIDs', 'sumForces', 'sumMoments', 'sum_forces', 'sum_moments', 'thermalMaterialIDs', 'unresolveGrids', 'unresolve_grids', 'updateSolution', 'update_solution', 'writeBDF', 'writeBDFAsPatran', 'write_as_CTRIA3', 'write_bdf']\n---BDF Statistics---\nSOL 103\n\nbdf.params\n  PARAM:   8\n\nbdf.nodes\n  GRID:    5380\n\nbdf.elements\n  CBAR:    827\n  CBUSH:   104\n  CHEXA:   25\n  CONM2:   15\n  CQUAD4:  4580\n  CTRIA3:  32\n\nbdf.rigidElements\n  RBE2:    44\n\nbdf.properties\n  PBAR:    1\n  PBARL:   18\n  PBUSH:   2\n  PSHELL:  8\n  PSOLID:  4\n\nbdf.materials\n  MAT1:    14\n  MAT8:    8\n\nbdf.coords\n  CORD2R:  75\n\nbdf.methods\n  EIGRL:   1\n\nRejected Cards\n  USET:    1\n\n{u'PARAM': 8, u'CQUAD4': 4580, u'PSOLID': 4, u'PBUSH': 2, u'CBUSH': 104, u'PBARL': 18, u'MAT1': 14, u'CTRIA3': 32, u'CORD2R': 75, u'PSHELL': 8, u'USET': 1, u'GRID': 5380, u'EIGRL': 1, u'CBAR': 827, u'PBAR': 1, u'CHEXA': 25, u'SPC': 1, u'CONM2': 15, u'RBE2': 44, u'MAT8': 8}\n"
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "# explanation of cross-referencing\n\n# no cross referencing (xref=False)\ncquad = bdf.elements[1]\nnid1 = cquad.nodes[0]\nn1 = bdf.nodes[nid1]\ncd4 = n1.cd\nc4 = bdf.coords[cd4]\nprint \"i xref=False\", c4.i\n#print object_attributes(c4)\n\n# cross referenced (xref=True)\nprint \"i xref=True\", bdf2.elements[1].nodes[0].cd.i\n\n# how is it done?\ncquad.nodes[0] = n1\nprint cquad.nodes[0]",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "i xref=False [ 1.  0.  0.]\ni xref=True [ 1.  0.  0.]\n$*\n$*  GRID CARDS\n$*\nGRID           1       4    -4.5    -7.5    -14.       4\n\n"
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "# some Grid methods\nn1 = bdf2.nodes[1]\nprint n1\n\n# the comment\nc1 = bdf2.nodes[1].comment()\nc2 = bdf2.nodes[2].comment()\nprint \"c1=%r\" % c1\nprint \"c2=%r\" % c2\n\n\n# get the position of a node\n# in the local cooordinate system\nprint \"xyz =\", n1.xyz\n\n# in the global frame\nprint \"position =\", n1.Position()\n\n# in an arbitrary frame\nprint \"wrt5 =\", n1.PositionWRT(bdf2, 5)\nprint \"wrt4 =\", n1.PositionWRT(bdf2, 4)",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "$*\n$*  GRID CARDS\n$*\nGRID           1       4    -4.5    -7.5    -14.       4\n\nc1=u'$*\\n$*  GRID CARDS\\n$*\\n'\nc2=u''\nxyz = [ -4.5  -7.5 -14. ]\nposition = [ -4.5  -7.5 -14. ]\nwrt5 = [  2.12132034  14.         -26.59188309]\nwrt4 = [ -4.5  -7.5 -14. ]\n"
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "n1 = bdf2.nodes[1]\nn1.xyz[1] = -7.5\nprint \"repr  =\", n1.reprFields()\nprint \"raw   =\", n1.rawFields()\n\n#n1.xyz[1] = 100000000000.\nprint \"repr2 =\", n1.reprFields()\nprint n1",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "repr  = [u'GRID', 1, 4, -4.5, -7.5, -14.0, 4, '', None]\nraw   = [u'GRID', 1, 4, -4.5, -7.5, -14.0, 4, '', 0]\nrepr2 = [u'GRID', 1, 4, -4.5, -7.5, -14.0, 4, '', None]\n$*\n$*  GRID CARDS\n$*\nGRID           1       4    -4.5    -7.5    -14.       4\n\n"
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "print \"mass = \", bdf2.Mass()",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "mass =  "
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "1.77460115784\n"
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "eid100 = bdf2.elements[100]\nprint eid100\nprint \"nodes =\", eid100.nodes\nprint \"--node0--\\n\", eid100.nodes[0]\nprint \"--cd--\\n\", eid100.nodes[0].cd\nprint \"cd.cid\", eid100.nodes[0].cd.cid\n\nprint \"area =\", eid100.Area()\nprint \"mass =\", eid100.Mass()\nprint \"--pid--\\n\", eid100.pid\nprint \"pid.pid =\", eid100.pid.pid\nprint \"pid.Pid() =\", eid100.Pid()\n\nprint eid100.pid.mid1\nprint \"type =\", eid100.pid.mid1.type\nprint \"nu12 =\", eid100.pid.mid1.nu12\nprint \"mass =\", eid100.Mass()",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "CQUAD4       100       1     149     152     161     160\n\nnodes = [GRID         149       4      3.     7.5   -16.5       4\n, GRID         152       4     1.5     7.5   -16.5       4\n, GRID         161       4     1.5     7.5    -14.       4\n, GRID         160       4      3.     7.5    -14.       4\n]\n--node0--\nGRID         149       4      3.     7.5   -16.5       4\n\n--cd--\nCORD2R         4              0.      0.      0.      0.      0.      1.\n              1.      0.      0.\n\ncd.cid 4\narea = 3.75\nmass = 3.6428803074e-05\n--pid--\n$*\n$*  PROPERTY CARDS\n$*\n$*\n$*  I-DEAS property: 1  name: BUS PNL HCMB 2PLY\nPSHELL         1       6    .036       61415.815       7  22.234 3.551-6\n              .4     -.4\n\npid.pid = 1\npid.Pid() = 1\n$*\n$*  I-DEAS Material: 6  name: BUS_CFRP_PW_ORTHO\n$* M46J PW ETW\nMAT8           6   1.7+7   1.7+7     .98 340000. 180000. 180000..0001712\n                           71.33\n\ntype = MAT8\nnu12 = 0.98\nmass = 3.6428803074e-05\n"
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "import getpass\nname = getpass.getuser()\nos.chdir(os.path.join(r'C:\\Users', name, 'Desktop'))",
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 10
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "pwd",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 11,
       "text": "u'C:\\\\Users\\\\Steve\\\\Desktop'"
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": "# write the bdf\nbdf2.write_bdf('fem.bdf', interspersed=True, size=8)\n!tail \"fem.bdf\"",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "DEBUG:     fname=bdf_writeMesh.pyc         lineNo=169    ***writing fem.bdf\n"
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "        -51.1378    20.1    -38.\nCORD2R        73            -7.5    20.1    -38.    -7.563.73783    -38.\n        -51.1378    20.1    -38.\nCORD2R        74            -7.5    20.1    -38.    -7.563.73783    -38.\n        -51.1378    20.1    -38.\nCORD2R        75        1.355-13-2.19-15    -40.1.355-13-2.19-15      0.\n             40.-2.19-15    -40.\nCORD2R        76        1.355-13-2.19-15    -40.1.355-13-2.19-15      0.\n             40.-2.19-15    -40.\nENDDATA\n"
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}